package com.apes.fn.scm.commodityInquiry.repository;


import com.apes.fn.scm.commodityInquiry.model.CommodityInquiryOrder;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface CommodityInquiryOrderRepository extends CustomRepository<CommodityInquiryOrder, String> {
    @Query(value = "" +
            "SELECT A.ID, A.SOURCE_BUSINESS_KEY, A.SOURCE_BUSINESS_TYPE, B.PRODUCT_ID " +
            "  FROM PUR_COMMODITY_INQUIRY_ORDER A, PUR_COMMODITY_INQUIRY_ITEM B " +
            " WHERE A.ID = B.COMMODITY_INQUIRY_ORDER_ID " +
            "   AND SOURCE_BUSINESS_KEY = :SOURCE_BUSINESS_KEY AND SOURCE_BUSINESS_TYPE = :SOURCE_BUSINESS_TYPE " +
            "   AND B.PRODUCT_ID IN (:PRODUCT_ID) ", nativeQuery = true)
    List<Map> queryCommodityInquiryProduct(@Param("SOURCE_BUSINESS_KEY") String SOURCE_BUSINESS_KEYv, @Param("SOURCE_BUSINESS_TYPE") String SOURCE_BUSINESS_TYPE, @Param("PRODUCT_ID") List PRODUCT_ID);
}
